package study.spring.mvc.server;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

/**
 * https://zhuanlan.zhihu.com/p/351541477
 */
@Slf4j
public class JettyServer {

    private static final String WEB_APP = System.getProperty("user.dir") + "\\src\\main\\webapp";
    private static final String CTX_PATH = "/";
    private static final int PORT = 8080;

    @SneakyThrows
    public static void main(String[] args) {
        WebAppContext webapp = new WebAppContext(WEB_APP, CTX_PATH);
        Server server = new Server(PORT);
        server.setHandler(webapp);

        server.start();
        server.join();
    }
}
